{{ 'template-collection.css' | asset_url | stylesheet_tag }}
{{ 'component-loading-overlay.css' | asset_url | stylesheet_tag }}
{{ 'component-card.css' | asset_url | stylesheet_tag }}
{{ 'component-price.css' | asset_url | stylesheet_tag }}

<link rel="preload" href="{{ 'component-rte.css' | asset_url }}" as="style" onload="this.onload=null;this.rel='stylesheet'">

{%- if section.settings.enable_quick_add -%}
  <link rel="stylesheet" href="{{ 'quick-add.css' | asset_url }}" media="print" onload="this.media='all'">
  <script src="{{ 'quick-add.js' | asset_url }}" defer="defer"></script>
  <script src="{{ 'product-form.js' | asset_url }}" defer="defer"></script>
{%- endif -%}
<noscript>{{ 'component-rte.css' | asset_url | stylesheet_tag }}</noscript>

{%- style -%}
  .section-{{ section.id }}-padding {
    padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
    padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
  }
  
  #Details-Mobile-1-{{ section.id }}{
    display: none;
  }

  @media screen and (min-width: 750px) {
    .section-{{ section.id }}-padding {
      padding-top: {{ section.settings.padding_top }}px;
      padding-bottom: {{ section.settings.padding_bottom }}px;
    }
  }
{%- endstyle -%}
<style>
  .e-bikes-collection {
    background: #f8f8f8;
  }
  .main-collection-card-product {
    margin-top: 15px;
  }
  .main-collection-card-product .product-grid {
    gap: 24px;
  }
  .product-form__input {
    flex: 0 0 100%;
    padding: 0;
    margin: 0 0 1.8rem;
    max-width: 37rem;
    min-width: fit-content;
    border: none;
  }
  .e-bikes-collection #product-grid {
    margin-left: 0;
  }
  .main-collection-card-product #product-grid .grid__item {
    width: calc(100% /3 - 48px / 3);
    max-width: calc(100% /3 - 48px / 3);
    padding-left: 0;
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
  }
  fieldset.product-form__input .form__label {
    margin-bottom: 0.2rem;
    color: #8d8d8d;
    font-weight: bold;
    font-size: 14px;
  }
  .product-grid-column {
    margin-top: 40px;
  }
  .product-grid-container {
    margin-bottom: 80px;
  }

  .product-form__input input[type='radio'] {
    clip: rect(0, 0, 0, 0);
    overflow: hidden;
    position: absolute;
    height: 1px;
    width: 1px;
  }
  .product-form__input.color input[type=radio]+label {
    background: transparent;
    border: none;
    width: 22px;
    height: 22px;
    display: inline-block;
    vertical-align: middle;
    text-align: center;
    line-height: 24px;
    cursor: pointer;
  }
  .product-form__input.color input[type=radio]+label img {
    width: 13px;
    height: 13px;
    user-select: none;
  }
  .product-form__input.color input[type=radio]:checked+label {
    border: 1.3px solid #2F80ED !important;
    border-radius: 24px;
    line-height: 22px;
  }
  .varanits-wrapper {
    position: relative;
  }
  .learn-more-button {
    position: absolute;
    right: 40px;
    top: 5px;
    color: var(--web-primary-color-100, #2F80ED);
    font-family: Montserrat;
    font-size: 14px;
    font-style: normal;
    font-weight: 700;
    line-height: 22px; /* 157.143% */
    text-decoration: none;
  }
  .learn-more-button svg {
    margin-left: 8px;
  }
  .learn-more-button path {
    stroke: var(--web-primary-color-100, #2F80ED);
  }
  .card--standard > .card__content .card__information {
    overflow: hidden;
  }
  .main-collection-card-product .card__inner .card__badge {
    top: 0;
  }
  .card__information .card__heading {
    color: #000;
    font-size: 16px;
    font-style: normal;
    font-weight: 700;
    line-height: 24px; /* 150% */
    margin: 0;
  }
  .main-collection-card-product .card-wrapper .media--transparent {
    background-color: unset;
  }
  .card__desc {
    text-align: left;
    color: var(--grey-60, #8D8D8D);
    font-family: Montserrat;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: 22px;
    white-space: nowrap;
    overflow: hidden; 
    text-overflow: ellipsis;
    padding-top: 4px;
  }
  .card-information .price__sale .price-item, .card-information .price__regular .price-item--regular {
    color: #000;
    font-size: 18px;
    font-style: normal;
    font-weight: 700;
    line-height: 16px;
  }
  .card-information .price--on-sale .price__sale {
    display: flex;
    align-items: baseline;
  }
  .card-information .price__sale .price-item--regular {
    color: var(--grey-40, #CCC);
    font-family: Montserrat;
    font-size: 16px;
    font-style: normal;
    font-weight: 400;
    text-decoration-line: strikethrough;
  }
  
  .card__badge .badge__sale {
    background-color: #47D7AC;
  }
  
  .card__badge .badge__new {
    background: linear-gradient(35deg, #2F80ED 50.96%, #9EC4F8 94.49%), #2F80ED;
  }
  .facets-wrapper {
    padding-bottom: 40px;
  }
  .filter-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .filter-wrapper .colection-title {
    color: #000;
    /* 36px Bold 48px */
    font-size: 36px;
    font-style: normal;
    font-weight: 700;
    line-height: 48px; /* 133.333% */
  }
  .filter-wrapper .facet-filters__field .facet-filters__label label {
    color: #000;
    text-align: center;
    font-size: 16px;
    font-style: normal;
    font-weight: 700;
    line-height: 24px; /* 150% */
  }
  .affirm-text {
    color: #000;
    /* 12px regular 20px */
    font-family: Montserrat;
    font-size: 12px;
    font-style: normal;
    font-weight: 400;
    line-height: 20px;
  }
  .affirm-text .affirm-modal-trigger {
    text-decoration: none;
    color: #000;
  }
  
  .price-wrapper {
    display: flex;
    padding: 1rem 0 3.6rem;
  }
  .price-wrapper .price__sale .price-item--last {
    margin: 0;
  }
  .price-wrapper .tenways-regular_price .price-item--regular {
    margin: 0;
  }
  .affirm-wrapper {
    margin-left: 10px;
  }
  .badge {
    background-color: #47D7AC;
    border: none;
  }
  .facets__disclosure {
    display: none;
  }
  .facets__wrapper .facets__heading {
    display: none;
  }
  .color.product-form__input {
    margin: 0;
  }
  .card--media .card__inner .card__content {
    position: static;
  }
  .card--standard .card__inner {
    position: relative;
  }
  .card--standard .card__inner::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    padding-bottom: var(--ratio-percent);
  }
  .card--standard .card__inner .card__media {
    position: absolute;
    top: 0;
    bottom: 0;
    height: 100%;
    width: 100%;
  }
  .card--standard .card__inner .card__media .media {
    height: 100%;
  }
  
  .collection-card-product__title {
    color: #000;
    font-size: 36px;
    font-style: normal;
    font-weight: 700;
    line-height: 48px;
  }
  .card-column-title {
    height: 136px;
    margin-bottom: 40px;
    font-size: 48px;
    font-style: normal;
    line-height: 48px; /* 100% */
    position: relative;
    overflow: hidden;
  }
  .card-column-title .card-column-title_media {
    border-radius: 8px;
  }
  .card-column-title__text {
    position: absolute;
    z-index: 1;
    color: #fff;
    padding: 44px 0 44px 40px;
  }
  .card-column-title__text p {
    margin: 0;
  }
  .main-collection-card-product .card__content {
    margin: 0;
  }
  .main-collection-card-product .card__media .media img {
    height: 100%;
    width: 100%;
    object-position: center center;
    object-fit: cover;
  }
  @media screen and (min-width: 990px) {
    .pc-media {
      display: block;
    }
    .mobile-media {
      display: none;
    }
    .media.media--hover-effect a > img + img  {
      opacity: 0;
    }
    .card .media.media--hover-effect a > img:only-child,
    .card__inner .media.media--hover-effect a > img:only-child {
      transition: transform var(--duration-long) ease;
    }
  
    .card__inner:hover
      .media.media--hover-effect
      a > img:first-child:not(:only-child) {
      opacity: 0;
    }
  
    .card__inner:hover .media.media--hover-effect a > img + img {
      opacity: 1;
    }
    .card__inner .media img {
      display: block;
      max-width: 100%;
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      width: 100%; 
    }
  }
  
  @media screen and (max-width: 990px) {
    .learn-more-button {
      right: 0;
    }
    .product-grid-container {
      margin-bottom: 20px;  
    }
    .e-bikes-collection .content-for-layout{
      margin-top: 40px;
    }
    .collection-card-product__title {
      color: #000;
      font-size: 18px;
      font-style: normal;
      font-weight: 700;
      line-height: 26px; /* 144.444% */
      text-align: center;
    }
    .pc-media {
      display: none;
    }
    .mobile-media {
      display: block;
    }
    
    .affirm-wrapper {
      line-height: 1;
    }
    .e-bikes-collection .price-wrapper  .price--on-sale .price__sale {
      display: flex;
    }
    .card-information .price__regular .price-item--regular {
      display: inline-block;
      vertical-align: top;
    }
    .filter-wrapper .colection-title {
      display: none;
    }
    .e-bikes-collection .header-wrapper {
      background: #000;
    }
    .shopify-section-header-hidden .header-wrapper {
      background-color: #fff;
    }
    .facets-container {
      width: 100%;
    }
    
    .e-bikes-collection #product-grid {
      margin-left: 0;
      flex-direction: column;
    }
    .card-column-title {
      height: unset;
      margin: 20px 0;
      font-size: 16px;
      font-weight: 700;
      line-height: 100%;
      font-style: normal;
      position: relative;
      overflow: hidden;
    }
    .card-column-title .card-column-title_media {
      border-radius: 0;
    }
    .card-column-title__text {
      padding: 25px 0 0 25px;
    }
    .main-collection-card-product #product-grid .grid__item {
      width: 100%;
      max-width: 100%;
      padding-left: 0;
      background-color: #fff;
      border-radius: 8px;
      padding: 20px;
    }
    .product-grid-column {
      margin-top: 20px;
    }
  }
  
  @media screen and (max-width: 750px) {
    .collection-for-banner__text-wrapper {
      width: 90%;
      padding: 0 20px;
    }
    .collection-for-banner__text-wrapper .collection-for-banner__title {
      color: #FFF;
      text-align: center;
      /* 24px Bold 32px */
      font-size: 24px;
      font-style: normal;
      font-weight: 700;
      line-height: 32px; /* 133.333% */ 
      letter-spacing: 0.5px;
    }
    
    .collection-for-banner__text-wrapper .collection-for-banner__description {
      color: #FFF;
      text-align: center;
      /* 16px regular 24px */
      font-size: 16px;
      font-style: normal;
      font-weight: 400;
      line-height: 24px; /* 150% */
      padding-top: 8px;
    }
  }
</style>
<div class="section-{{ section.id }}-padding main-collection-card-product">
  <div class="collection-card-product__container">
    <div class="collection-card-product__title page-width">
      {{ collection.title }}
    </div>
    <div class="product-grid-column">
      {% for block in section.blocks %}
        {%  assign handle = block.settings.handle %}
        <div class="card-column-title page-width">
          <div class="card-column-title__text">{{ block.settings.title }}</div>
          <div
            class="card-column-title_media media pc-media"
            {% if block.settings.image != blank %} style="padding-bottom: {{ 1 | divided_by: block.settings.image.aspect_ratio | times: 100 }}%;"{% endif %}
          >
            <img
              srcset="{%- if block.settings.image.width >= 165 -%}{{ block.settings.image | image_url: width: 165 }} 165w,{%- endif -%}
                {%- if block.settings.image.width >= 360 -%}{{ block.settings.image | image_url: width: 360 }} 360w,{%- endif -%}
                {%- if block.settings.image.width >= 533 -%}{{ block.settings.image | image_url: width: 533 }} 533w,{%- endif -%}
                {%- if block.settings.image.width >= 720 -%}{{ block.settings.image | image_url: width: 720 }} 720w,{%- endif -%}
                {%- if block.settings.image.width >= 940 -%}{{ block.settings.image | image_url: width: 940 }} 940w,{%- endif -%}
                {%- if block.vimage.width >= 1066 -%}{{ block.settings.image | image_url: width: 1066 }} 1066w,{%- endif -%}
                {{ block.settings.image | image_url }} {{ block.settings.image.width }}w"
              src="{{ block.settings.image | image_url: width: 533 }}"
              alt="{{ block.settings.image.alt | escape }}"
              class=""
              {% unless lazy_load == false %}loading="lazy"{% endunless %}
              width="{{ block.settings.image.width }}"
              height="{{block.settings.image.height }}"
            >
          </div>
          <div
            class="card-column-title_media media mobile-media"
            {% if block.settings.mobile_image != blank %} style="padding-bottom: {{ 1 | divided_by: block.settings.mobile_image.aspect_ratio | times: 100 }}%;"{% endif %}
          >
            <img
              srcset="{%- if block.settings.image.width >= 165 -%}{{ block.settings.mobile_image | image_url: width: 165 }} 165w,{%- endif -%}
                {%- if block.settings.mobile_image.width >= 360 -%}{{ block.settings.mobile_image | image_url: width: 360 }} 360w,{%- endif -%}
                {%- if block.settings.mobile_image.width >= 533 -%}{{ block.settings.mobile_image | image_url: width: 533 }} 533w,{%- endif -%}
                {%- if block.settings.mobile_image.width >= 720 -%}{{ block.settings.mobile_image | image_url: width: 720 }} 720w,{%- endif -%}
                {%- if block.settings.mobile_image.width >= 940 -%}{{ block.settings.mobile_image | image_url: width: 940 }} 940w,{%- endif -%}
                {%- if block.mobile_image.width >= 1066 -%}{{ block.settings.mobile_image | image_url: width: 1066 }} 1066w,{%- endif -%}
                {{ block.settings.mobile_image | image_url }} {{ block.settings.mobile_image.width }}w"
              src="{{ block.settings.mobile_image | image_url: width: 533 }}"
              alt="{{ block.settings.mobile_image.alt | escape }}"
              class=""
              {% unless lazy_load == false %}loading="lazy"{% endunless %}
              width="{{ block.settings.mobile_image.width }}"
              height="{{block.settings.mobile_image.height }}"
            >
          </div>
        </div>
        <div class="product-grid-container page-width" id="ProductGridContainer">
          {%- paginate collection.products by section.settings.products_per_page -%}
            <div class="collection">
              <div class="loading-overlay gradient"></div>
              <ul id="product-grid" data-id="{{ section.id }}" class="
                grid product-grid grid--{{ section.settings.columns_mobile }}-col-tablet-down
                grid--{{ section.settings.columns_desktop }}-col-desktop">
                {%- for product in collection.products -%}
                  {% assign lazy_load = false %}
                  {%- if forloop.index > 2 -%}
                    {%- assign lazy_load = true -%}
                  {%- endif -%}
                  {% if product.metafields.custom.collection_handle == handle %}
                  <li class="grid__item">
                    {% render 'card-product-color',
                      card_product: product,
                      media_aspect_ratio: section.settings.image_ratio,
                      show_secondary_image: section.settings.show_secondary_image,
                      show_vendor: section.settings.show_vendor,
                      show_rating: section.settings.show_rating,
                      lazy_load: lazy_load,
                      show_quick_add: section.settings.enable_quick_add,
                      section_id: section.id,
                      button_label: section.settings.btn
                    %}
                  </li>
                  {% endif %}
                {%- endfor -%}
              </ul>
              {%- if paginate.pages > 1 -%}
                {% render 'pagination', paginate: paginate, anchor: '' %}
              {%- endif -%}
            </div>
          {%- endpaginate -%}
        </div>
      {% endfor %}
    </div>
  </div>
</div>

<script>
  $(() => {
    var screen_width = window.screen.width;
    //根据屏幕分辨率判断是否是手机
    if(screen_width < 990){
      $('.card-column-title').removeClass('page-width');
    }
  })
</script>


{% schema %}
{
  "name": "Product Grid E-bkies",
  "tag": "section",
  "class": "section section-collection-ebikes",
  "settings": [
    {
      "type": "range",
      "id": "products_per_page",
      "min": 8,
      "max": 24,
      "step": 4,
      "default": 16,
      "label": "t:sections.main-collection-product-grid.settings.products_per_page.label"
    },
    {
      "type": "range",
      "id": "columns_desktop",
      "min": 1,
      "max": 5,
      "step": 1,
      "default": 4,
      "label": "t:sections.main-collection-product-grid.settings.columns_desktop.label"
    },
    {
      "type": "header",
      "content": "t:sections.main-collection-product-grid.settings.header__3.content"
    },
    {
      "type": "select",
      "id": "image_ratio",
      "options": [
        {
          "value": "adapt",
          "label": "t:sections.main-collection-product-grid.settings.image_ratio.options__1.label"
        },
        {
          "value": "portrait",
          "label": "t:sections.main-collection-product-grid.settings.image_ratio.options__2.label"
        },
        {
          "value": "square",
          "label": "t:sections.main-collection-product-grid.settings.image_ratio.options__3.label"
        }
      ],
      "default": "adapt",
      "label": "t:sections.main-collection-product-grid.settings.image_ratio.label"
    },
    {
      "type": "checkbox",
      "id": "show_secondary_image",
      "default": false,
      "label": "t:sections.main-collection-product-grid.settings.show_secondary_image.label"
    },
    {
      "type": "checkbox",
      "id": "show_vendor",
      "default": false,
      "label": "t:sections.main-collection-product-grid.settings.show_vendor.label"
    },
    {
      "type": "checkbox",
      "id": "show_rating",
      "default": false,
      "label": "t:sections.main-collection-product-grid.settings.show_rating.label",
      "info": "t:sections.main-collection-product-grid.settings.show_rating.info"
    },
    {
      "type": "checkbox",
      "id": "enable_quick_add",
      "default": false,
      "label": "t:sections.main-collection-product-grid.settings.enable_quick_buy.label"
    },
    {
      "type": "header",
      "content": "t:sections.main-collection-product-grid.settings.header__1.content"
    },
    {
      "type": "checkbox",
      "id": "enable_filtering",
      "default": true,
      "label": "t:sections.main-collection-product-grid.settings.enable_filtering.label",
      "info": "t:sections.main-collection-product-grid.settings.enable_filtering.info"
    },
    {
      "type": "select",
      "id": "filter_type",
      "options": [
        {
          "value": "horizontal",
          "label": "t:sections.main-collection-product-grid.settings.filter_type.options__1.label"
        },
        {
          "value": "vertical",
          "label": "t:sections.main-collection-product-grid.settings.filter_type.options__2.label"
        },
        {
          "value": "drawer",
          "label": "t:sections.main-collection-product-grid.settings.filter_type.options__3.label"
        }
      ],
      "default": "horizontal",
      "label": "t:sections.main-collection-product-grid.settings.filter_type.label",
      "info": "t:sections.main-collection-product-grid.settings.filter_type.info"
    },
    {
      "type": "checkbox",
      "id": "enable_sorting",
      "default": true,
      "label": "t:sections.main-collection-product-grid.settings.enable_sorting.label"
    },
    {
      "type": "header",
      "content": "t:sections.main-collection-product-grid.settings.header_mobile.content"
    },
    {
      "type": "select",
      "id": "columns_mobile",
      "default": "2",
      "label": "t:sections.main-collection-product-grid.settings.columns_mobile.label",
      "options": [
        {
          "value": "1",
          "label": "t:sections.main-collection-product-grid.settings.columns_mobile.options__1.label"
        },
        {
          "value": "2",
          "label": "t:sections.main-collection-product-grid.settings.columns_mobile.options__2.label"
        }
      ]
    },
    {
      "type": "header",
      "content": "t:sections.all.padding.section_padding_heading"
    },
    {
      "type": "range",
      "id": "padding_top",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_top",
      "default": 36
    },
    {
      "type": "range",
      "id": "padding_bottom",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_bottom",
      "default": 36
    },
    {
      "type": "text",
      "id": "btn",
      "default": "Learn More",
      "label": "Button Label"
    }
  ],
  "blocks":[
    {
      "type": "Tag",
      "name": "Tag",
      "settings": [
        {
          "type": "text",
          "id": "handle",
          "label": "handle"
        },
        {
          "type": "richtext",
          "id": "title",
          "label": "Title"
        },
        {
          "type": "image_picker",
          "id": "image",
          "label": "Image"
        },
        {
          "type": "image_picker",
          "id": "mobile_image",
          "label": "Mobile Image"
        }
      ]
    }
  ],
  "presets": [
    {
      "name": "Product Grid E-bkies"
    }
  ]
}
{% endschema %}